﻿<Application 
    x:Class="Stopwatch.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

    <!--应用程序资源-->
    <Application.Resources>
        <Style x:Name="smallBorder" TargetType="Border">
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="CornerRadius" Value="50"/>
            <Setter Property="BorderThickness" Value="3"/>
        </Style>
        <Style x:Name="largeBorder" TargetType="Border">
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="CornerRadius" Value="100"/>
            <Setter Property="BorderThickness" Value="10"/>
        </Style>

        <!-- for help -->
        <Style x:Name="helpStartIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/start.png" />
        </Style>
        <Style x:Name="helpPauseIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/pause.png" />
        </Style>
        <Style x:Name="helpPausedState" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/paused.png" />
        </Style>
        <Style x:Name="helpSplitIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/split.png" />
        </Style>
        <Style x:Name="helpResetIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/reset.png" />
        </Style>
        <Style x:Name="helpWindowsIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/windows.png" />
        </Style>
        <Style x:Name="helpTileIcon" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/tile.png" />
        </Style>
        <Style x:Name="helpTimepicker" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/help/timepicker.png" />
        </Style>
        <!-- end for help -->
        
        <!-- for control buttons-->
        <ControlTemplate x:Key="resetButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneAccentBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
  Storyboard.TargetName="border"
  Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                  Storyboard.TargetName="border"
                  Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneChromeBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="icon"
                Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Dark/Images/reset-disabled.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="border" Background="{TemplateBinding Background}" Style="{StaticResource smallBorder}">
                    <Image x:Name="icon" Source="/Themes/Dark/Images/reset.png"/>
                </Border>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="startButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneAccentBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
  Storyboard.TargetName="border"
  Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneChromeBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="icon"
                Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Dark/Images/start-disabled.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="border" Style="{StaticResource largeBorder}">
                    <Image x:Name="icon" Source="/Themes/Dark/Images/start.png"/>
                </Border>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="pauseButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneAccentBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
  Storyboard.TargetName="border"
  Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneChromeBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="icon"
                Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Dark/Images/pause-disabled.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="border" Style="{StaticResource largeBorder}">
                    <Image x:Name="icon" Source="/Themes/Dark/Images/pause.png"/>
                </Border>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="addButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneAccentBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
  Storyboard.TargetName="border"
  Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                    Storyboard.TargetName="border"
                    Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneChromeBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                    Storyboard.TargetName="icon"
                    Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Dark/Images/add-disabled.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="border" Background="{TemplateBinding Background}" Style="{StaticResource smallBorder}">
                    <Image x:Name="icon" Source="/Themes/Dark/Images/add.png"/>
                </Border>
            </Grid>
        </ControlTemplate>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--处理应用程序的生存期事件所需的对象-->
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>